package com.yanchangapp.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.R;
import com.yanchangapp.commom.RecordStatus;
import com.yanchangapp.model.bean.RecordListBean;
import com.zxl.baselib.util.ui.ResHelper;

import java.util.List;

/**
 * Created by apple on 2019-08-23.
 * description:采购记录adapter
 */
public class RecordListAdapter extends BaseQuickAdapter<RecordListBean, BaseViewHolder> {

    public RecordListAdapter(int layoutResId, @Nullable List<RecordListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RecordListBean item) {
        // 设置姓名 + 部门
        helper.setText(R.id.tvRecordName,item.getBuyer());
        helper.setText(R.id.tvRecordDept,item.getDepartment());
        // 对时间进行设置...
        TextView tvTag = helper.getView(R.id.tvTag);
        tvTag.setVisibility(View.VISIBLE);
        tvTag.setText(item.getExamineStatusName());
        if (RecordStatus.WAIT_APPROVE.getStatus().equals(String.valueOf(item.getStatus()))){
            helper.setText(R.id.tvCreateTime,ResHelper.getString(R.string.apply_time,item.getCreateTime()));
            tvTag.setBackground(ResHelper.getDrawable(R.drawable.tag_order_submit));
        }else {
            helper.setText(R.id.tvCreateTime,ResHelper.getString(R.string.approve_time,item.getUpdateTime()));
            if (RecordStatus.HAS_PASS.getStatus().equals(String.valueOf(item.getStatus()))){
                tvTag.setBackground(ResHelper.getDrawable(R.drawable.tag_order_pass));
            }else {
                tvTag.setBackground(ResHelper.getDrawable(R.drawable.tag_order_reject));
            }
        }

    }
}
